
Partial Class Presentation_Management_OverallReporting
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim Sql As String
        Dim CountSql As String
        Dim Params(0) As GenParameter

        Page.Title = "Overall Reporting"

        'Make the query based on who is accessing 

        If Not User.IsInRole("Top Management") Then

            Sql = "SELECT ExecutiveName FROM ExecutiveMaster WHERE ExecutiveID NOT IN (SELECT ExecutiveID FROM WorkflowMaster WHERE MeetingDate BETWEEN DATE_SUB(DATE_ADD(NOW(), INTERVAL 630 MINUTE), INTERVAL 5 DAY) AND NOW())" & _
            " AND DepartmentID = 2 AND Active = 1 AND Location = ?Location" & _
            " ORDER BY ExecutiveName"

            CountSql = "SELECT COUNT(*) FROM ExecutiveMaster WHERE ExecutiveID NOT IN (SELECT ExecutiveID FROM WorkflowMaster WHERE MeetingDate BETWEEN DATE_SUB(DATE_ADD(NOW(), INTERVAL 630 MINUTE), INTERVAL 5 DAY) AND NOW())" & _
                " AND DepartmentID = 2 AND Active = 1 AND Location = ?Location" & _
                " ORDER BY ExecutiveName"



        Else

            Sql = "SELECT ExecutiveName FROM ExecutiveMaster WHERE ExecutiveID NOT IN (SELECT ExecutiveID FROM WorkflowMaster WHERE MeetingDate BETWEEN DATE_SUB(DATE_ADD(NOW(), INTERVAL 630 MINUTE), INTERVAL 5 DAY) AND NOW())" & _
           " AND DepartmentID = 2 AND Active = 1" & _
           " ORDER BY ExecutiveName"

            CountSql = "SELECT COUNT(*) FROM ExecutiveMaster WHERE ExecutiveID NOT IN (SELECT ExecutiveID FROM WorkflowMaster WHERE MeetingDate BETWEEN DATE_SUB(DATE_ADD(NOW(), INTERVAL 630 MINUTE), INTERVAL 5 DAY) AND NOW())" & _
                " AND DepartmentID = 2 AND Active = 1" & _
                " ORDER BY ExecutiveName"

        End If

        Params(0) = New GenParameter("?Location", Request.Cookies("Profile").Item("Location"), Data.DbType.String)


        cstmOverallReporting.Sql = Sql
        cstmOverallReporting.CountSql = CountSql
        cstmOverallReporting.Params = Params
        cstmOverallReporting.ShowButton = False
    End Sub
End Class
